/**
 * @param {number} k
 */
export var MyCircularQueue = function (k) {
  this.size = k
  this.queue = new Array(k)
  this.index = 0
  this.count = 0
}

/**
 * @param {number} value
 * @return {boolean}
 */
MyCircularQueue.prototype.enQueue = function (value) {
  if (this.count === this.size) return false
  this.queue[(this.index + this.count) % this.size] = value
  this.count += 1
  return true
}

/**
 * @return {boolean}
 */
MyCircularQueue.prototype.deQueue = function () {
  if (this.count === 0) return false
  this.index = (this.index + 1) % this.size
  this.count -= 1
  return true
}

/**
 * @return {number}
 */
MyCircularQueue.prototype.Front = function () {
  if (this.count === 0) return -1
  return this.queue[this.index]
}

/**
 * @return {number}
 */
MyCircularQueue.prototype.Rear = function () {
  if (this.count === 0) return -1
  let tailIndex = (this.index + this.count - 1) % this.size
  return this.queue[tailIndex]
}

/**
 * @return {boolean}
 */
MyCircularQueue.prototype.isEmpty = function () {
  return this.count === 0
}

/**
 * @return {boolean}
 */
MyCircularQueue.prototype.isFull = function () {
  return this.count === this.size
}

/**
 * Your MyCircularQueue object will be instantiated and called as such:
 * var obj = new MyCircularQueue(k)
 * var param_1 = obj.enQueue(value)
 * var param_2 = obj.deQueue()
 * var param_3 = obj.Front()
 * var param_4 = obj.Rear()
 * var param_5 = obj.isEmpty()
 * var param_6 = obj.isFull()
 */
